package client

import (
	"context"
	"github.com/2103A/message/goods"
	"github.com/zeromicro/go-zero/zrpc"
)

func goodClient() goods.GoodsClient {
	conn := zrpc.MustNewClient(zrpc.RpcClientConf{
		Target: "dns:///127.0.0.1:8184",
	})
	return goods.NewGoodsClient(conn.Conn())
}

func ExistGoodsSkuById(ctx context.Context, request *goods.GetGoodsSkuByIdRequest) (bool, error) {
	res, err := goodClient().GetGoodsSkuById(ctx, request)
	if err != nil {
		return false, err
	}

	return res.Data, nil
}

type GoodSkuInfo struct {
	Image string `json:"image"`
	Price string `json:"price"`
	Name  string `json:"name"`
}

func GetGoodsSkuById() GoodSkuInfo {
	return GoodSkuInfo{
		Image: "httt://www.baidu.com",
		Price: "99.9",
		Name:  "test",
	}
}
